package zpf.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import zpf.entity.User;
import zpf.feign.UserFeignHystrixFactoryClient;

import java.util.List;

/**
 * @ClassName: MovieFeignCustomWithoutHystrixController
 * @Description: TODO
 * @Autor: ZPF
 * @Date: 2021/1/15 9:42
 **/
@RestController
public class MovieFeignHystrixFactoryController {

    @Autowired
    private UserFeignHystrixFactoryClient userFeignHystrixFactoryClient;


    @GetMapping("/movie/{id}")
    public User findById(@PathVariable Long id) {
        System.out.println("== findById Controller " + Thread.currentThread().getThreadGroup() + " - " + Thread.currentThread().getId() + " - " + Thread.currentThread().getName());
        return userFeignHystrixFactoryClient.findById(id);
    }

    @GetMapping("/movie")
    public List<User> findAll(){
        System.out.println("== findAll Controller " + Thread.currentThread().getThreadGroup() + " - " + Thread.currentThread().getId() + " - " + Thread.currentThread().getName());
        return userFeignHystrixFactoryClient.findAll();
    }
}
